package com.tigerhhzz.springcloud.controller;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.tigerhhzz.springcloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author tigerhhzz
 * @date 2023/4/15 9:19
 */
@RestController
@Slf4j
public class PaymentController {

    @Resource
    private PaymentService paymentService;

    @Value("${server.port}")
    private String serverPort;

    @GetMapping("/payment/hystrix/ok/{id}")
    public String getPaymentInfo_OK(@PathVariable("id") Integer id){
        String res = paymentService.getPaymentInfo_OK(id);
        return res;
    }
    @GetMapping("/payment/hystrix/error/{id}")
    public String getPaymentInfo_Error(@PathVariable("id") Integer id){
        String res = paymentService.getPaymentInfo_Error(id);
        return res;
    }

    public String paymentInfo_ERROR_Handler(@PathVariable("id") Integer id){
        return "80____paymentInfo_ERROR_Handler___异常返回";
    }

    @GetMapping("/payment/hystrix/circuit/{id}")
    public String paymentCircuitBreaker(@PathVariable("id") Integer id){
        String res = paymentService.paymentCircuitBreaker(id);
        return res;
    }


}
